#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	const int MAXC = 16;
	const int MAXN = 64;
	bool kids[MAXN];
	memset(kids, false, sizeof(bool) * MAXN);
	char kidsNames[MAXN][MAXC];
	int N, W, S;
	cin>>N;
	for (int i = 0; i < N; i++) {
		cin>>kidsNames[i];
	}
	char c;
	cin >>W>>c>>S;
	int out = 0;
	int startIndex = W - 1;
	while (out < N) {
		int num = 0;
		while (num < S) {			
			if (!kids[startIndex])
				++num;
			++startIndex;
			startIndex %= N;
		}
		cout<<kidsNames[startIndex > 0 ? startIndex - 1 : N - 1]<<endl;
		kids[startIndex > 0 ? startIndex - 1 : N - 1] = true;
		++out;
	}
	return 0;
}